import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorkshopVO, WorkshopForm, WorkshopQuery } from '@/api/base/factory/workshop/types';

/**
 * 查询车间管理列表
 * @param query
 * @returns {*}
 */
export const listWorkshop = (query?: WorkshopQuery): AxiosPromise<WorkshopVO[]> => {
  return request({
    url: '/base/factory/workshop/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取车间管理列表
 * @param query
 * @returns {*}
 */
export const queryList = (query?: WorkshopForm): AxiosPromise<WorkshopForm[]> => {
  return request({
    url: '/base/factory/workshop/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询车间管理详细
 * @param id
 */
export const getWorkshop = (id: string | number): AxiosPromise<WorkshopVO> => {
  return request({
    url: '/base/factory/workshop/' + id,
    method: 'get'
  });
};

/**
 * 新增车间管理
 * @param data
 */
export const addWorkshop = (data: WorkshopForm) => {
  return request({
    url: '/base/factory/workshop',
    method: 'post',
    data: data
  });
};

/**
 * 修改车间管理
 * @param data
 */
export const updateWorkshop = (data: WorkshopForm) => {
  return request({
    url: '/base/factory/workshop',
    method: 'put',
    data: data
  });
};

/**
 * 删除车间管理
 * @param id
 */
export const delWorkshop = (id: string | number | Array<string | number>) => {
  return request({
    url: '/base/factory/workshop/' + id,
    method: 'delete'
  });
};

export default {
  queryList
};
